package com.api.phm.domain.model;

import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.Date;
import java.util.UUID;

@Data
public class FaultLogModel {
    private String faultId;
    private Long plcId;
    private Long lineId;
    private Long robotId;
    private Long elementId;
    private String datCol;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;
    private int faultLevel;
    private String faultCode;
    private String faultStatus;
    private String faultMessage;
    private JSONObject triggerValue;
    private String strTriggerValue;
    private String readMark = "N";

    public void setTriggerValue(JSONObject triggerValue) {
        this.triggerValue = triggerValue;
        this.strTriggerValue = triggerValue.toString();
    }

    public FaultLogModel() {
    }

    public FaultLogModel(String idTitle, Long plcId, Long lineId, Long robotId, Long elementId, String datCol, Date startTime, int faultLevel, String faultCode, String faultStatus, String faultMessage, JSONObject triggerValue, String strTriggerValue, String readMark) {
        this.faultId = idTitle + UUID.randomUUID();
        this.plcId = plcId;
        this.lineId = lineId;
        this.robotId = robotId;
        this.elementId = elementId;
        this.datCol = datCol;
        this.startTime = startTime;
        this.faultLevel = faultLevel;
        this.faultCode = faultCode;
        this.faultStatus = faultStatus;
        this.faultMessage = faultMessage;
        this.triggerValue = triggerValue;
        this.strTriggerValue = strTriggerValue;
        this.readMark = readMark;
    }
}
